﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace YasharEl.Infrastructure.ProcessEngine.DomainModel
{
    [ContractClass(typeof(ProcessProcessorContract))]
    public interface IProcessProcessor
    {
        IProcess StartProcess(long applicationId, long userId, long processDefinitionId, long owner, string comment, Dictionary<string, object> inputs);

        IProcess CancelProcess(long applicationId, long userId, Guid workflowInstanceId, string cancellationReason);
    }

    [ContractClassFor(typeof(IProcessProcessor))]
    internal abstract class ProcessProcessorContract : IProcessProcessor
    {
        #region IProcessProcessor Members

        public IProcess StartProcess(long applicationId, long userId, long processDefinitionId, long owner, string comment, Dictionary<string, object> inputs)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId should be valid positive number.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId should be valid positive number.");
            Contract.Requires<ArgumentNullException>(processDefinitionId > 0, "processDefinitionId should be valid positive number.");
            Contract.Requires<ArgumentNullException>(owner > 0, "owner should be valid positive number.");

            return default(IProcess);
        }

        public IProcess CancelProcess(long applicationId, long userId, Guid workflowInstanceId, string cancellationReason)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId should be valid positive number.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId should be valid positive number.");
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowIntanceId must be valid Guid.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(cancellationReason), "cancellationReason could not be null or empty.");

            return default(IProcess);
        }

        #endregion
    }
}
